<template>
  <div style="height: 100%; width: 100%">
    <!-- 学生班考试相关页面 -->
    
    <el-container style="background-color: aliceblue" min-height="650">
      考试管理<br>
      <el-main class="EmMainStyle">
        <!-- 数据更新 -->
        <el-table
          :data="classesSubjectInfoList"
          style="width: 100%"
          max-height="800"
        >
          <el-table-column fixed prop="subjectId" label="课程id" width="100">
          </el-table-column>

          <el-table-column
            fixed
            prop="subjectName"
            label="课程名称"
            width="100"
          >
          </el-table-column>

          <el-table-column fixed prop="studentExaminationId" label="学生考试id" width="100">
          </el-table-column>

          <el-table-column
            fixed
            prop="examinationId"
            label="考试id"
            width="100"
          >
          </el-table-column>
          <el-table-column
            fixed
            prop="examinationName"
            label="考试名字"
            width="100"
          >
          </el-table-column>

          <el-table-column
            fixed
            prop="studentId"
            label="学生id"
            width="100"
          >
          </el-table-column>

          <el-table-column
            fixed
            prop="studentName"
            label="学生名字"
            width="100"
          >
          </el-table-column>

          <el-table-column
            fixed
            prop="studentAccount"
            label="学生账号"
            width="100"
          >
          </el-table-column>

          <el-table-column
            fixed
            prop="studentXueHao"
            label="学生学号"
            width="100"
          >
          </el-table-column>
        </el-table>

        <div class="PageStyle">
          <el-pagination
            background
            layout="prev, pager, next"
            :total="counts"
            :page-size="pageSize"
            :current-page="pageNow"
            @current-change="pageChange"
            class="PageC"
          />
        </div>
      </el-main>
    </el-container>
  </div>
</template>
<script setup>
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from "@element-plus/icons-vue";
import { ref } from "vue";
import { ElMessage } from "element-plus";
import { studentStateStore } from "../store/StudentInfo.js";
import requests from "../axois/axios.js";
import {onMounted} from 'vue'
let studentStateStoreInfo = studentStateStore();


//定义数据数据集合
let classesSubjectInfoList = ref([]);

//定义翻页所需要的数据
let counts = 0;
let pageSize = 10;
let pageNow = 1;


//定义翻页所需要的的信息
function pageChange(index) {
  //传入的数据是当前的索引
  pageNow = index;
  //调用查询共嗯
  sendQueryMessage();
}
async function sendQueryMessage() {
  let { data } = await requests.post("/student/query/student/examination", {
    page: pageNow,
    pageSize: pageSize,
    studentId: studentStateStoreInfo.getterStudentId,
  });
  if (data.code == 200) {
    ElMessage({
      message: "查询成功",
      type: "success",
    });
    //数据设置
    classesSubjectInfoList.value = data.data;
    //页数设置
    counts = data.countTotal;
    pageSize = data.pageSize;
    pageNow = data.page;
  } else {
    ElMessage({
      message: "查询失败",
      type: "error",
    });
  }
}

//函数挂载
onMounted(()=>{
  sendQueryMessage()
})
</script>

<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 750px;
}
.RouterLinkStyle {
  text-decoration: none;
  color: rgb(247, 246, 236);
}
.EmMainStyle {
  width: 100%;
  height: 750px;
  background-color: aliceblue;
}
.PageStyle {
  display: flex;
  align-items: center;
}
</style>